import Cookies from 'js-cookie'
const TokenKey = 'x-access-token'
const RefreshTokenKey = 'x-refresh-token'
export function getToken() {
    return Cookies.get(TokenKey)
}

export function getConfig() {
  let config={};
  var hostname = location.hostname;
  var ccid = /^([a-zA-Z0-9.-]+\.)+cciddata\.com$/;   
  if(ccid.test(hostname) === true ){
    config.domain=".cciddata.com";
  }
  
  return config;
}

export function setToken(token) {
    return Cookies.set(TokenKey, token,getConfig())
}

export function getRefreshToken() {
  return Cookies.get(RefreshTokenKey)
}

export function setRefreshToken(token) {
  return Cookies.set(RefreshTokenKey, token,getConfig())
}

export function removeToken() {
    return Cookies.remove(TokenKey,getConfig())
}

export function removeRefreshToken() {
  return Cookies.remove(RefreshTokenKey,getConfig())
}

